package com.sky.controller.user;

import com.sky.constant.StatusConstant;
import com.sky.entity.Setmeal;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.DishItemVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
*@author: 夏帮连
*@date: 2025/06/24
*@description: 
*@version: 1.0
*/
@RestController("userSetmealController")
@Slf4j
@RequestMapping("/user/setmeal")
@Api("小程序菜品")
public class SetmealController {
    @Autowired
    private SetmealService setmealService;
    @GetMapping("/list")
    @ApiOperation("根据分类ID查询套餐")
    @Cacheable(cacheNames = "setmealCache",key="#categoryId")
    public Result<List<Setmeal>> list(Long categoryId) {
        Setmeal setmeal = Setmeal.builder().categoryId(categoryId).status(StatusConstant.ENABLE).build();
        List<Setmeal> list=setmealService.list(setmeal);
        return Result.success(list);
    }
    @GetMapping("/dish/{id}")
    @ApiOperation("根据套餐id查询菜品")
    public Result<List<DishItemVO>> dish(@PathVariable Long id) {
        List<DishItemVO> list=setmealService.getDishItemVOBySetmealId(id);
        return Result.success(list);
    }

}
